package com.cskaoyan.service;

import com.cskaoyan.bean.WxUserInfoBean;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @USER: cuiweiguo#
 * @DATE: 2022/5/10
 * @TIME: 16:47
 * @PROJECT_NAME: mallproject2
 */
@Service
public class WxUserServiceImpl implements WxUserService {
    @Autowired
    UserMapper userMapper;

    /**
     * @Description:
     * @Author: cuiweiguo#
     * @Date: 2022/5/10 16:49
     * @Param: [username, password]:
     * @return: int:
     **/
    @Override
    public int queryUserByUsernameAndPassword(String username, String password) {
        int count = userMapper.queryUserByUsernameAndPassword(username, password);
        if (count == 1) {
            return 200;
        }
        return 0;
    }

    @Override
    public Integer queryAdminIdByUsernameAndPassword(String username, String password) {
        int roleId = userMapper.queryUserIdByUsernameAndPassword(username, password);
        return roleId;
    }

    /**
     * @Description:
     * @Author: cuiweiguo#
     * @Date: 2022/5/10 17:00
     * @Param: [userId]:
     * @return: com.cskaoyan.bean.WxUserInfoBean:
     **/
    @Override
    public WxUserInfoBean queryUserInfoByUserId(Integer userId) {
        WxUserInfoBean wxUserInfoBean = userMapper.queryUserInfoByUserId(userId);
        return wxUserInfoBean;
    }

    @Override
    public String queryUserNameById(Integer userId) {
        String name = userMapper.queryUserNameById(userId);
        return name;
    }
}
